package ru.tulupov.toyfactory.model;

import java.util.Random;

public enum ToyType {
	DOLL(0.5), CAR(0.25), KNIFE(0.1);

	private double probability;

	private ToyType(double probability) {
		this.probability = probability;
	}

	public void playWithToy() {
		Random random = new Random();
		double number = random.nextDouble();

		if (number < probability) {
			throw new ToyBrokenException();
		}
	}
}